# Contributor: Oleg Titov <oleg.titov@gmail.com>
# Maintainer: Oleg Titov <oleg.titov@gmail.com>
pkgname=iozone
pkgver=3.490
_pkgver=${pkgver//./_}
pkgrel=0
pkgdesc="IOzone filesystem benchmark."
url="http://iozone.org"
arch="all !mips !mips64"
license="custom"
options="!check" # No test suite from upstream
subpackages="$pkgname-doc"
source="http://iozone.org/src/current/iozone$_pkgver.tar"
builddir="$srcdir/${pkgname}$_pkgver/"

build() {
	local target=
	case "$CARCH" in
		x86_64) target="linux-AMD64" ;;
		x86) target="linux" ;;
		aarch64) target="linux-arm" ;;
		armv7) target="linux-arm" ;;
		armhf) target="linux-arm" ;;
		s390x) target="linux-S390X" ;;
		ppc64le) target="linux-powerpc64" ;;
		*) msg "Unable to determine architecture from (CARCH=$CARCH)" ; return 1 ;;
	esac

	cd "$builddir"/src/current/
	make $target CFLAGS='-DHAVE_PREADV -DHAVE_PWRITEV'
}

package() {
	install -m755 -D src/current/iozone \
		"$pkgdir"/usr/bin/iozone

	install -dm755 "$pkgdir"/usr/share/licenses/$pkgname/
	sed -n '1,49p' "$builddir"/src/current/iozone.c > \
		"$pkgdir/usr/share/licenses/$pkgname/LICENSE"

	install -Dm644 "$builddir"/docs/iozone.1 \
		"$pkgdir"/usr/share/man/man1/iozone.1
}

sha512sums="15959cdb0a1f94cbe0063c72666683a5c2d8221dba04c7548ca96ac0ac5edf6118ccd54f1d4fd55151dbad79fc886bdd440a409b7906b4f6c0465c1f770fbcc6  iozone3_490.tar"
